<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page import="cn.chinaunicom.sdsi.frm.sys.R.ProResource"%>
<c:set var="appPath" scope="page" value="<%=ProResource.getAppPath() %>"/>
<c:set var="appName" scope="page" value="${pageContext.request.contextPath}"/>
<c:set var="frmPrefix" scope="page" value="${appName}${appPath}"/>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path;
%>
<!DOCTYPE html>
<html lang="zh_CN">
  <head>
  	<meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no">
  	<link rel="stylesheet" href="<%=basePath %>/resource/css/style.css"/>
	<script type="text/javascript" src="<%=basePath %>/resource/js/jquery/jquery-1.12.4.min.js"></script>
	<title>解决方案</title>
	<script type="text/javascript">
		var pageNo = 0;   //页号
		var pageSize = 10;  //页大小
		var min_height;
		$(document).ready(function(){
			$(window).scroll(function(){
				var scrollTop = $(this).scrollTop();
				var scrollHeight = $(document).height();
				var windowHeight = $(this).height();
				if(scrollTop + windowHeight == scrollHeight){
					//滚动条滚动到底部时，加载数据
					loadInfoData();
				}
			});
			
			min_height = $(window).height()*0.25;

			$(window).scroll(function(){
				var s = $(window).scrollTop();
				if(s > min_height){
					$(".cd-top").fadeIn(100);
				}else{
					$(".cd-top").fadeOut(100);
				}
			});
			$(".cd-top").click(function(){
				$("html,body").animate({
					scrollTop : "0px"
				});
			});
			
			//展示隐藏搜索框
			$("#aa").click(function(){
				$("#ii").toggle();
			});
			
			//搜索
			$("#fullText").click(function(){
				loadInfoData();
			});
		});
		//上一个检索关键字
		var pre_name = "";
		//当前检索关键字
		var name = "";
		
		//-----------------------------------------全文检索--------------------------------------
		function loadInfoData(){
			name = $("#search_key").val();
			if(!$("#content").is(":empty")&&(pre_name != name)){
				$("#content").html("");
				//重设页号
				pageNo = 0;
			}
			//设置起始页
			start = (pageNo == 0 ? 0 : pageNo*pageSize - 1);
			
			//发送请求load数据
			$.ajax({
				url:"${frmPrefix}/info/fullText.action",
				type:"post",
				data:{name:name,start:start,pageSize:pageSize},
				dataType:"json",
				success:function(data){
					console.log(data);
					$.each(data.list,function(i,n){
						$("#content").append("<li class='o-pic'><a href='${frmPrefix}/info/infoDetail.action?id="+ n.id +"'><em>"+ n.title +"</em><p>"+ n.content +"</p>"+
								"<i class='list-icon-keyword'>"+ (typeof(n.cont_label)=='undefined'?'智慧城市':n.cont_label) +"</i>"+
								"<i class='list-icon-name'>"+ (typeof(n.author)=='undefined'?'韩梅梅':n.author) +"</i>"+
								"<i class='list-icon-time'>"+ n.publish_date +"</i></a></li>");
					});
				}
			});
			//设置是否进行全文检索
			pageNo += 1;
			pre_name = name;
		};
	</script>
	<style type="text/css">

	</style>
  </head>
  <body onload="loadInfoData();">
  	<header class="header">
	  <h1 class="page-tit">解决方案</h1>
	    <a href="/upf/test.jsp" class="h-link-l waves-effect waves-icon waves-light"><i class="nav-icon-l"></i>返回</a>
		<a href="javascript:void(0);" class="h-link-r waves-effect waves-icon waves-light" id="aa"><i class="nav-icon-r"></i>查询</a>
		<div id="ii" class="search-expand" style="display: block;">
            <input type="text" class="search input" id="search_key" placeholder="请输入关键词" x-webkit-speech="" value=${keyword }>
            <button type="button" class="tip-bottom" title="搜索" id="fullText"><i class="icon-search"></i></button>
		</div>
	</header>

  	<ul class="news-list b-news-list clearfix" id="content">
	</ul>
	<a class="cd-top"></a>
  </body>
</html>